from collections import namedtuple


class TENANT:
    # 租户详情
    TENANT_DETAIL_INFO = "tenant:detail:{tenant_id}"
    # 租户的邀请码集合  -- 元素是租户的邀请码
    TENANT_INVITE_CODE_SET = "tenant:invite_code"
    # 租户用户集合[管理端]  -- 元素是用户id
    TENANT_USER_SET = "tenant:{tenant_id}:user:set"

    TENANT_PAYWAY_SET = "tenant:{tenant_id}:payway:set"


class MALL:
    # mall详情
    mall_detail_by_code = "mall:code:{code}"


class CACHE_SPU:
    # spu的详情
    spu_detail_by_id = "spu:detail:{spu_id}"
    # spu下面所有的sku的库存信息
    spu_sku_stock_hash = "spu:stock:hash:{spu_id}"


class CACHE_SKU:
    # sku详细信息
    sku_detail_by_id = "sku:detail:{sku_id}"
    # sku库存信息
    sku_stock_by_id = "sku:stock:{sku_id}"


class CACHE_STOCK:
    # 创建spu库存信息锁
    SET_SPU_STOCK_LOCK = "stock:spu:{spu_id}"
    # 更新sku库存信息锁
    SET_SKU_STOCK_LOCK = "stock:sku:{sku_id}"


class TENANT_USER:
    # 用户详情
    user_detail_by_id = "tuser:detail:{user_id}"
    # 用户详情 by email
    USER_DETAIL_BY_EMAIL = "tuser:detail:{email}"

class LANGUAGE:
    # 所有的语言集合
    TOTAL_LANGUAGE_SET = "language:total:set"
    # 所有语言信息
    TOTAL_LANGUAGE_INFO = "language:info"


class CURRENCY:
    # 所有的币种集合
    TOTAL_CURRENCY_SET = "currency:total:set"
    # 所有币种信息
    TOTAL_CURRENCY_INFO = "currency:info"
    # 某币种换算到其余币种的汇率
    CURRENCY_RATE_BY_CODE = "currency:{code}:rate"


class PAYWAY:
    TOTAL_PAY_WAY_SET = "payway:total:set"
    TOTAL_PAY_WAY_INFO = "payway:info"


DATAORCODE = namedtuple("DATAORCODE", "data,code,msg", defaults=[None, 0, ''])